package io.jboot.admin.service.api;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import io.jboot.admin.service.entity.model.Log;

import java.util.List;

public interface LogService  {

    /**
     * 分页查询数据字典信息
     * @param log
     * @param pageNumber
     * @param pageSize
     * @return
     */
    public Page<Log> findPage(Log log, int pageNumber, int pageSize);

    /**
     * 根据ID查找model
     *
     * @param id
     * @return
     */
    public Log findById(Object id);


    /**
     * 根据ID删除model
     *
     * @param id
     * @return
     */
    public boolean deleteById(Object id);

    /**
     * 删除
     *
     * @param model
     * @return
     */
    public boolean delete(Log model);


    /**
     * 保存到数据库
     *
     * @param model
     * @return
     */
    public Object save(Log model);

    /**
     * 保存或更新
     *
     * @param model
     * @return
     */
    public Object saveOrUpdate(Log model);

    /**
     * 更新 model
     *
     * @param model
     * @return
     */
    public boolean update(Log model);

    public <M extends Model> Page<M> join(Page<M> page, String joinOnField);
    public <M extends Model> Page<M> join(Page<M> page, String joinOnField, String[] attrs);
    public <M extends Model> Page<M> join(Page<M> page, String joinOnField, String joinName);
    public <M extends Model> Page<M> join(Page<M> page, String joinOnField, String joinName, String[] attrs);


    public <M extends Model> List<M> join(List<M> models, String joinOnField);
    public <M extends Model> List<M> join(List<M> models, String joinOnField, String[] attrs);
    public <M extends Model> List<M> join(List<M> models, String joinOnField, String joinName);
    public <M extends Model> List<M> join(List<M> models, String joinOnField, String joinName, String[] attrs);

    /**
     * 添加关联数据到某个model中去，避免关联查询，提高性能。
     *
     * @param model       要添加到的model
     * @param joinOnField model对于的关联字段
     */
    public <M extends Model> M join(M model, String joinOnField);

    /**
     * 添加关联数据到某个model中去，避免关联查询，提高性能。
     *
     * @param model
     * @param joinOnField
     * @param attrs
     */
    public <M extends Model> M join(M model, String joinOnField, String[] attrs);


    /**
     * 添加关联数据到某个model中去，避免关联查询，提高性能。
     *
     * @param model
     * @param joinOnField
     * @param joinName
     */
    public <M extends Model> M join(M model, String joinOnField, String joinName);


    /**
     * 添加关联数据到某个model中去，避免关联查询，提高性能。
     *
     * @param model
     * @param joinOnField
     * @param joinName
     * @param attrs
     */
    public <M extends Model> M join(M model, String joinOnField, String joinName, String[] attrs);
}